package com.graphhopper.util.obstacle;

import com.graphhopper.vo.ObstacleVo;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Administrator
 */
public class AirObstacleUtils {

    public static List<ObstacleVo> getObstacleList(int key) {
        return BuildingSelect.obstacleVo(key);
    }

    public static List<Integer> gitIndex(Integer min, Integer max) {
        List<Integer> indexList = new ArrayList<>();
        if (min == null || max == null) {
            return indexList;
        }
        if (min < 40) {
            min = 40;
        }
        if (min > 200) {
            return indexList;
        }
        if (max < 40 || max > 200) {
            return indexList;
        }
        if (min > max) {
            return indexList;
        }
        int minIndex = getIndex(min);
        int maxIndex = getIndex(max);

        indexList.add(minIndex);
        indexList.add(maxIndex);

        List<Integer> uniqueList = indexList.stream().distinct().collect(Collectors.toList());
        if (uniqueList.size() == 1) {
            return uniqueList;
        }
        List<Integer> sortInfo = uniqueList.stream().sorted().collect(Collectors.toList());
        int minTemp = sortInfo.get(0);
        int maxTemp = sortInfo.get(1);
        indexList = new ArrayList<>();
        for (int i = minTemp; i <= maxTemp; i++) {
            indexList.add(i);
        }
        return indexList;
    }

    public static void main(String[] args) {
        int min = 20;
        int max = 122;
        List<Integer> list = gitIndex(min, max);
        list.forEach(a -> {
            System.out.print(a + ",");
        });
    }

    private static int getIndex(int height) {

        if (height <= 60) {
            return 1;
        }

        if (height <= 80) {
            return 2;
        }

        if (height <= 100) {
            return 3;
        }

        if (height <= 120) {
            return 4;
        }

        if (height <= 140) {
            return 5;
        }

        if (height <= 160) {
            return 6;
        }

        if (height <= 180) {
            return 7;
        }

        if (height <= 200) {

            return 8;
        }
        return 0;
    }
}
